﻿<?php
include("../class/mysql.class.php");
include("../submit/Articles/get_list_article.php");
$obj = new Mysql ();
// hedhia stat 2
$rq  = "select * from st_attr_sortie where id_article=".$_POST['id_article'];
$rq.= " AND Date_cmd >= '".$_POST['dateD']."' AND Date_cmd <= '".$_POST['dateF']."'";
$rs = mysql_query($rq);
$data = '[';
$dataT = '[';
while($row = mysql_fetch_object($rs)){
  //echo $row->id_article;
  $data.= getPrixVenteArticle($_POST['id_article']).',';
  $dataT.= "'".$row->Date_cmd."',";
}
$dataT.=']';
$data.=']';
echo $dataT;
echo $data;
?>
<script src="lib/jquery.js"></script>
<script>
      
        var chart2;
        // globally available 
        jQuery(document).ready(function($){
          $(function(){
          // Radialize the colors
          Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
              return {
                  radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
                  stops: [
                      [0, color],
                      [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
                  ]
              };
          });
      });
            chart2 = new Highcharts.Chart({
            chart: {
              renderTo: 'containerSTAT',
                  },
                  title: {
                      text: <?php echo "'".getDesignation($_POST['id_article'])."'" ?>
                  },
                  xAxis: {
                    /* liste mensuel dynamique */
                      categories: <?php echo $dataT ?>,
                      title: { text: 'Periode' }
                  },
                  tooltip: {
                      formatter: function() {
                          var s;
                          if (this.point.name) { // the pie chart
                              s = ''+
                                  this.point.name +': '+ this.y +' ';
                          } else {
                              s = ''+
                                  this.x  +': '+ this.y+' TND';
                          }
                          return s;
                      }
                  },
                  series: [
                  {
                      type: 'column',
                      name: 'Prix',
                      data: <?php echo $data ?>
                  }
                  ]
              });
          });
</script>
         <div id='containerSTAT' style='width: 800px; height: 400px; margin: 0 auto'></div>
         
